﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Billing.DataObjects;
using System.Linq;
namespace Billing.Transactions
{
    public partial class PaymentOrdersForm : Billing.WindowsBase.BaseList
    {
        public PaymentOrdersForm()
            : this(true)
        {
        }

        public PaymentOrdersForm(bool Register)
            : base(Register)
        {
            InitializeComponent();
        }
        BillingDataContext mBillingDataContext;
        public BillingDataContext BillingDataContext
        {
            get
            {
                if (mBillingDataContext == null)
                    mBillingDataContext = new BillingDataContext();
                return mBillingDataContext;
            }
            set { mBillingDataContext = value; }
        }
        protected override void onDataLoad()
        {
            base.onDataLoad();


            this.bsElement.DataSource = from i in BillingDataContext.PaymentOrders
                                        where i.PaymentOrderTypeID == 1 && (i.PaymentOrderStatusID == 1 || i.PaymentOrderStatusID == 4)
                                        orderby i.DocumentDate descending
                                        select i;
            
        }
        protected override void onElementInitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
            base.onElementInitializeLayout(sender, e);
            this.ElementNameID = "ID";


            e.Layout.Bands[0].Columns["PaymentOrderTypeID"].Hidden = true;
            e.Layout.Bands[0].Columns["PaymentOrderStatusID"].Hidden = true;
            e.Layout.Bands[0].Columns["ClientID"].Hidden = true;
            e.Layout.Bands[0].Columns["Account"].Hidden = true;
            e.Layout.Bands[0].Columns["FileID"].Hidden = true;
            e.Layout.Bands[0].Columns["RowVersion"].Hidden = true;
            e.Layout.Bands[0].Columns["Phone"].Hidden = true;
            e.Layout.Bands[0].Columns["File"].Hidden = true;
            e.Layout.Bands[0].Columns["DocumentNumber"].Hidden = true;
            e.Layout.Bands[0].Columns["PaymentOrderStatuse"].Hidden = true;
            e.Layout.Bands[0].Columns["PaymentPointID"].Hidden = true;
            e.Layout.Bands[0].Columns["CreatorID"].Hidden = true;
            e.Layout.Bands[0].Columns["ModifierID"].Hidden = true;
            e.Layout.Bands[0].Columns["Key"].Hidden = true;
            e.Layout.Bands[0].Columns["Name"].Hidden = true;
            e.Layout.Bands[0].Columns["Value"].Hidden = true;
            e.Layout.Bands[0].Columns["CurrentObject"].Hidden = true;

            e.Layout.Bands[0].Columns["ID"].Header.VisiblePosition = 0;
            e.Layout.Bands[0].Columns["ID"].Width = 60;
            e.Layout.Bands[0].Columns["DocumentDate"].Header.VisiblePosition = 1;
            e.Layout.Bands[0].Columns["DocumentDate"].Width = 70;
            e.Layout.Bands[0].Columns["DocumentDate"].Header.Caption = "თარიღი";
            e.Layout.Bands[0].Columns["DocumentDate"].Format = "dd.MM.yyyy";
            e.Layout.Bands[0].Columns["Description"].Header.VisiblePosition = 2;
            e.Layout.Bands[0].Columns["Description"].Width = 110;
            e.Layout.Bands[0].Columns["Description"].Header.Caption = "აღწერა";
            e.Layout.Bands[0].Columns["IdentificationNumber"].Header.VisiblePosition = 3;
            e.Layout.Bands[0].Columns["IdentificationNumber"].Width = 60;
            e.Layout.Bands[0].Columns["IdentificationNumber"].Header.Caption = "ს/კ";
            e.Layout.Bands[0].Columns["Amount"].Header.VisiblePosition = 5;
            e.Layout.Bands[0].Columns["Amount"].Width = 50;
            e.Layout.Bands[0].Columns["Amount"].Header.Caption = "თანხა";
            e.Layout.Bands[0].Columns["Amount"].Format = "#,##0.00";
            //e.Layout.Bands[0].Columns["Amount"].mas = "#,##0.00";
            e.Layout.Bands[0].Columns["PaymentPoint"].Header.VisiblePosition = 8;
            e.Layout.Bands[0].Columns["PaymentPoint"].Width = 130;
            e.Layout.Bands[0].Columns["PaymentPoint"].Header.Caption = "გადახდის წერტილი";
            e.Layout.Bands[0].Columns["ModifiedDate"].Header.VisiblePosition = 9;
            e.Layout.Bands[0].Columns["ModifiedDate"].Width = 115;
            e.Layout.Bands[0].Columns["ModifiedDate"].Header.Caption = "შეიცვალა";
            e.Layout.Bands[0].Columns["ModifiedDate"].Format = "dd.MM.yyyy hh:mm:ss";
            e.Layout.Bands[0].Columns["CreatedDate"].Header.VisiblePosition = 10;
            e.Layout.Bands[0].Columns["CreatedDate"].Width = 115;
            e.Layout.Bands[0].Columns["CreatedDate"].Header.Caption = "შეიქმნა";
            e.Layout.Bands[0].Columns["CreatedDate"].Format = "dd.MM.yyyy hh:mm:ss";
            e.Layout.Bands[0].Columns["ErrorDescription"].Header.VisiblePosition = 11;
            e.Layout.Bands[0].Columns["ErrorDescription"].Width = 150;
            e.Layout.Bands[0].Columns["ErrorDescription"].Header.Caption = "შეცდომა";
        }

    }
}
